package com.gu.controller;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.gu.VO.LayuiVO;
import com.gu.VO.ServerResponse;
import com.gu.entity.Setting;
import com.gu.entity.VehicleRefuelingRule;
import com.gu.service.SettingService;
import com.gu.service.VehicleRefuelingRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.UnsupportedEncodingException;

/**
 * @Author: gusongliao
 * @Description: 车辆加油控制类
 * @createDate 2023/01/05 19:32
 */
@Controller
@RequestMapping("/setting")
public class SettingController {

    @Autowired
    private SettingService settingService;

    @RequestMapping("/settingList")
    @ResponseBody
    public LayuiVO userList(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "15") Integer pageSize, String module, String name) throws UnsupportedEncodingException {
        PageInfo settingList = settingService.settingList(pageNum, pageSize, module, name);
        return LayuiVO.success(settingList.getTotal(),settingList.getList());
    }

    @RequestMapping("/updateSetting")
    @ResponseBody
    public ServerResponse getAllVehicleInfo(String record) {
        Setting setting = JSON.parseObject(record, Setting.class);
        return settingService.updateSetting(setting);
    }



}
